from numpy import array
from scipy.cluster.vq import vq, kmeans, whiten
from dml.CLUSTER.kmeans_iter import KMEANSC
import matplotlib.pyplot as plt
features=array([
[13.45,11.95],
[14.15,11.75],
[14.8,11.25],
[15.35,10.35],
[15,9.55],
[14.05,9.3],
[13.05,10.2],
[13.5,11.3],
[14.4,10.95],
[14.85,10.05],
[13.75,9.65],
[13.85,10.65],
[14.15,10.6],
[14.3,9.95],
[13.85,9.5],
[13.3,10.6],
[13.25,11.45],
[12.8,11],
[13.95,9.2],
[14.85,9.65],
[10.4,13.95],
[10.05,13.9],
[9.55,12.75],
[9.3,11.75],
[9.3,10.5],
[9.7,9.1],
[10.4,8.25],
[11.65,7.05],
[12.9,6.45],
[13.85,6.35],
[15.3,6.65],
[16.7,7.4],
[17.5,8.25],
[18.25,9.05],
[18.75,10.2],
[18.65,11.35],
[18.25,12.5],
[17.4,13.75],
[16.6,14.75],
[15.05,15.35],
[12.7,15.25],
[10.55,14.55],
[9.95,13.95],
[9.3,12.65],
[9.1,11],
[9.2,10],
[10.2,8.65],
[10.85,7.7],
[12,7],
[13.2,6.55],
[14.45,6.6],
[15.4,6.8],
[16.9,7.15],
[17.35,7.55],
[18.05,8.45],
[18.35,9.2],
[18.75,9.8],
[18.9,10.35],
[18.9,11.05],
[18.8,12.15],
[18.3,12.65],
[17.8,13.4],
[16.95,14.15],
[16.1,14.8],
[14.8,15.35],
[13.55,15.35],
[11.6,15],
[10.4,14.25],
[11.3,14.4],
[12.2,15.15],
[12.45,15.35],
[13.05,15.4],
[13.85,15.25]]
).transpose()
a=KMEANSC(features,2)
a.train(180)
print a.result()
for i in range(features.shape[1]):
	if  a.labels[i]==0:
		plt.plot(features[0][i],features[1][i],'or')
	elif a.labels[i]==1:
		plt.plot(features[0][i],features[1][i],'ob')
	else:
		plt.plot(features[0][i],features[1][i],'oy')
plt.show()
#print a.result()
#print a.bfWhiteCen()